<template>
  <div class="particulars">
    <div class="main">
      <el-input
        v-model="input"
        placeholder="此处内容已隐藏，建议购买后查看"
        clearable
      ></el-input>

      <div class="button">
        <div class="list" @click="addConfirm">保存</div>
      </div>
    </div>
  </div>
</template>

<script>
import { commonsystemData, commonsystemDataAdd } from "@/api/common";

export default {
  data() {
    return {
      partcularsObj: {},
      loading: true,
      input: "",
    };
  },
  created() {
    this.loading = true;
    this.commonsystemDataMet();
  },
  methods: {
    commonsystemDataMet() {
      let params = {};

      commonsystemData(params).then((res) => {
        if (res.errorCode == null) {
          res.resultData.forEach((item, index) => {
            if (item.systemId == 4) {
              this.partcularsObj = item;
              this.input = item.value;

              this.loading = false;
            }
          });
        }
      });
    },

    addConfirm() {
      if (this.$store.state.premissions.infoRouterShow == false) {
        this.$message.error("暂无权限，请联系管理员开通");
        return;
      }

      if(this.input == '') {
        this.input = '此处内容已隐藏，建议购买后查看'
      }
      let params = {
        systemId: this.partcularsObj.systemId,
        key: this.partcularsObj.key,
        value: this.input,
      };

      commonsystemDataAdd(params).then((res) => {
        if (res.errorCode == null) {
          this.$message.success("编辑配置成功！");
          this.loading = true;
          this.commonsystemDataMet();
        }
      });
    },
  },
};
</script>

<style lang="less" scoped>
.particulars {
  .main {
    /deep/ .el-input {
      width: 400px;
    }

    .button {
      display: flex;
      align-items: center;
      margin-top: 40px;
      margin-bottom: 70px;

      .list {
        background: #3da8f5;
        color: #fff;
        font-size: 16px;
        margin-right: 20px;
        border-radius: 5px;
        width: 80px;
        height: 35px;
        display: flex;
        align-items: center;
        justify-content: center;
        cursor: pointer;
      }
    }
  }
}
</style>